<?php

require_once '/DAL/DbHelper.php';
require_once '/Model/ApplicationEntity.php';

/**
 * This class is used to support the facualty role function
 */
class Controller_Faculty {

    public $ControllerName = 'Controller_Faculty';
    public $DbHelper = null;
    public $UserEntity = null;

    /**
     * The default Constructor
     */
    public function __construct() {
        $this->DbHelper = new DbHelper();
        $this->UserEntity = $_SESSION["UserEntity"];
    }

    /**
     * Create New Application
     * @param type $applicationEntity
     * @return type
     */
    public function CreateNewApplication($applicationEntity) {
        $strSQL = "call Proc_Faculty_CreateNewApplication(?,?,?,?,?,?,?,?)";
        $parameters[] = $applicationEntity->ApplicationTypeID;
        $parameters[] = $applicationEntity->ActionUserID;
        $parameters[] = $applicationEntity->RefferenceName;
        $parameters[] = $applicationEntity->RefferenceID;
        $parameters[] = $applicationEntity->RefferenceTypeID;
        $parameters[] = $applicationEntity->ApplicationComment;
        $parameters[] = $applicationEntity->ApplicationHandleSchoolIDs;
        $parameters[] = $applicationEntity->FileList;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * the accordion tab data 
     *
     * @return type
     */
    public function QuerySummary() {
        $strSQL = "call Proc_Faculty_QuerySummary";
        $res = $this->DbHelper->execSqlStatement($strSQL);
        return $res;
    }

    /**
     * the Accordion tab statistic
     * @param type $SchoolID
     * @return typet
     */
    public function QuerySummaryDetail($SchoolID) {
        $strSQL = "call Proc_Faculty_QuerySummaryDetail(?)";
        $parameters[] = $SchoolID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * Accordion Detail View ,push the Data For the Tab
     * @param type $SchoolID
     * @param type $ApplicationID
     * @return type
     */
    public function QueryAccordionDetail($SchoolID, $ApplicationID) {
        $strSQL = "call Proc_Faculty_QueryAccordionDetail(?,?)";
        $parameters[] = $SchoolID;
        $parameters[] = $ApplicationID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * Accept Application
     * @param type $entity
     * @return type
     */
    public function AcceptApplication($entity) {
        $strSQL = "call Proc_Faculty_Accept(?,?,?,?,?,?)";
        $parameters[] = $entity->rowApplicationID;
        $parameters[] = $entity->rowHandleSchoolID;
        $parameters[] = $entity->rowStateID;
        $parameters[] = $entity->rowActionUserID;
        $parameters[] = $entity->newActionUserID;
        $parameters[] = $entity->newActionStateID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * Faculty Add Supllemnt File History
     * @param type $fileSupplementEntity
     * @return type
     */
    public function AddFiles($fileSupplementEntity) {
        $strSQL = "call Proc_Faculty_AddFile(?,?,?,?,?,?,?,?)";
        $parameters[] = $fileSupplementEntity->rowApplicationID;
        $parameters[] = $fileSupplementEntity->rowHandleSchoolID;
        $parameters[] = $fileSupplementEntity->rowStateID;
        $parameters[] = $fileSupplementEntity->rowActionUserID;
        $parameters[] = $fileSupplementEntity->newActionUserID;
        $parameters[] = $fileSupplementEntity->newActionStateID;
        $parameters[] = $fileSupplementEntity->newActionComment;
        $parameters[] = $fileSupplementEntity->FileList;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

}

?>
